package client.unbelonged.simple_factory;

import org.junit.Test;
import org.xml.sax.SAXException;
import uml.unbelonged.simple_factory.Chart;
import uml.unbelonged.simple_factory.ChartFactory;
import util.xml.XMLUtil;

import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;

/**
 * 简单工厂:<br>
 * 1.工厂类负责创建的对象比较少，或者工厂类创建对象的逻辑不会太复杂<br>
 * 2.客户端只需要知道传入工厂类的参数，对如何创建对象不关心<br>
 * on 2022/12/13 23:23
 */
public class Client {
    @Test
    public void t() throws ParserConfigurationException, IOException, SAXException {
        String chartType = XMLUtil.getValueOfFirstTagOfConfigFile(
                new File("src\\main\\resources\\xml\\simple_factory.xml"),
                "chartType");
        Chart chart = ChartFactory.getChart(chartType);
        chart.display();
    }
}
